//
//  LFBSearchModel.m
//  LFBLoveFreshBee
//
//  Created by Cain on 16/8/21.
//  Copyright © 2016年 丁鼎. All rights reserved.
//

#import "LFBSearchModel.h"


@implementation LFBSearchModel

+ (void)getSearchArrayWithSuccessBlock:(void(^)(NSArray *))successBlock errorBlock:(void(^)())errorBlock
{
    NSMutableArray *marr = [NSMutableArray array];
    
    [[LFBNetworkingTool sharedTool] getdataWithRequestTpye:LFBRequestTypeSearch WithSuccessBlock:^(NSDictionary *responseObject) {
        
        NSDictionary *rootKey = responseObject[@"data"];
        NSArray *arr = rootKey[@"hotquery"];
        
        [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            //把UTF-8string转换为NSString
            NSString *str = [arr[idx] stringByRemovingPercentEncoding];
            [marr addObject:str];
            
        }];
        
        if (successBlock) {
            successBlock(marr.copy);
        }
        
    } OrFailureBlock:^(NSError *error) {
        if (errorBlock) {
            errorBlock();
        }
    }];
    
}

@end
